package com.emmy.walnut.util;

import com.emmy.walnut.model.Record;
import com.emmy.walnut.model.RecordByDate;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName BusinessUtil
 * @Description 和业务相关的单元
 * @Author zhouxuan
 * @Date 2020/02/11 11:32
 * @Version 1.0
 */
public class BusinessUtil {
    public static List<Object> getRecordWithDate(List<Record> records){
        List<Object> results = new ArrayList<>();
        if (records==null||records.size()==0){
            return results;
        }
        long currentTimestamp = records.get(0).getStartTimestamp();
        results.add(currentTimestamp);
        for (Record record:records){
            if (TimeStampUtil.isSameDate(currentTimestamp, record.getStartTimestamp())){
                results.add(record);
            }else{
                currentTimestamp = record.getStartTimestamp();
                results.add(currentTimestamp);
                results.add(record);
            }
        }
        return results;
    }
}
